package cn.edu.scau.cmi.zhengweibo.chapter7;
public class Japan implements Computable { ////Japan类实现Computable接口
   int number;
   public int f(int x) {
      return 46+x; 
   }
}

interface  ShowMessage {
   void 显示商标(String s);
}
class TV implements ShowMessage {
   public void 显示商标(String s) {
      System.out.println(s);
   }
}
class PC implements ShowMessage {
   public void 显示商标(String s) {
     System.out.println(s);
   }
}
public class Example7_2 {
   public static void main(String args[]) {
      ShowMessage sm;                  //声明接口变量
      sm=new TV();                     //接口变量中存放对象的引用
      sm.显示商标("长城牌电视机");      //接口回调。
      sm=new PC();                     //接口变量中存放对象的引用
      sm.显示商标("联想奔月5008PC机"); //接口回调
   } 
}

interface CompurerAverage {
   public double average(double a,double b);
}
class A implements CompurerAverage {
   public double average(double a,double b) {
      double aver=0;
      aver=(a+b)/2;
      return aver;
   }
}
class B implements CompurerAverage {
   public double average(double a,double b) {
      double aver=0;
      aver=Math.sqrt(a*b);
      return aver;
   }
}
public class Example7_3 {
   public static void main(String args[]) {
      CompurerAverage computer;
      double a=112,b=126;
      computer=new A();  
      double result= computer.average(a,b);
      System.out.println(a+"和"+b+"的算术平均值："+result);
      computer=new B();  
      result= computer.average(a,b);
      System.out.println(a+"和"+b+"的几何平均值："+result);
   } 
}
